<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>原型继承和借用构造函数</title>
</head>
<body>
<script type="text/javascript">
    function Person() {
    }
    function Base() {
        //父类
        //实例属性  -> 借用构造函数 apply call
        this.clothing = ["trousers","dress","jacket"];
    }
    //原型属性 -> 原型链 XX.prototype = new XX();
    Base.prototype.type = "花";

    function Flower(name) {
        Base.call(this);//借用构造函数  继承关系没了
        //定义属性 赋值
        //this  实例属性
        this.name = name;
        this.showName = function () {
            alert(this.name)
        }
    }
    let base = new Base(); //同一个对象
    //原型对象赋值
    Flower.prototype = base;//另一个原型对象的实例

    //使用 new
    var fl1 = new Flower("牡丹");
    var fl2 = new Flower("月季");
    // fl1.showName();

    //控制台  //指针 -> 一个对象 Object 顶级父类
    console.log(fl2 instanceof Object) //顶级父类
    console.log(fl2 instanceof Base) //父类
    console.log(fl2 instanceof Flower)

    fl1.clothing.push("T恤");
    console.log(fl1.clothing)

    console.log(fl2.clothing)

    base.clothing.push("上衣")
    console.log(base.clothing)
</script>
</body>
</html>